﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace paraInterface
{
    public class PLC
    {

        public string IP { get; set; }
        public string ADD { get; set; }
        public int Port { get;set; }
        public byte SUB { get; set; }
        public int DATALENTH { get; set; }
        public bool isRealPLC { get; set; }

        public virtual  bool InitPLC()
        {
           return isRealPLC = false;
        }
        public virtual bool SendData2PLC(jsonData data)//需要将数据进行解析
        {
            return false;
        }

        public bool IsIP(string ip)
        {
            if (string.IsNullOrEmpty(ip)) return false;
            ip = ip.Trim();
            string pattern = @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$";
            return Regex.IsMatch(ip, pattern);
        }
       
    }
}
